<?php include("template/baglanti.php"); include ("template/upload.php"); include("template/header.php"); ?>   
<link rel="stylesheet" type="text/css" href="css/main.css" />
<?php
		$ok = ""; 
		$id = intval($_GET['id']);
		
		//Categori Listeleme
		$query = ("SELECT * FROM `categori` WHERE `categori_id` ='$id'");
		$sql = mysql_query($query);
		$row = mysql_fetch_assoc($sql);		
		$save = $_POST['save'];
		$photo= $row['categori_photo'];
		
		if ($save) {



			//Categori Düzenleme
			$categori_name = $_POST['categori_name'];
			$categori_namecn = $_POST['categori_namecn'];
			$categori_info = $_POST['categori_info'];
			$categori_infocn = $_POST['categori_infocn'];
			$categori_show_list = $_POST['categori_show_list'];
			$categori_language = $_POST['categori_language'];
			$categori_show = $_POST['categori_show'];
			$dosya = $_FILES['dosya'];
			if ( $dosya['name'] != '') {
			$photo = upload_pic($dosya);	
			}
			
							
	
			@mysql_query("update  categori  set 
			
			`categori_name` 		= '$categori_name',
			`categori_namecn` 		= '$categori_namecn',  
			`categori_info` 		= '$categori_info',  
			`categori_infocn` 		= '$categori_infocn',  
			`categori_photo` 		= '$photo', 
			`categori_show_list` 	= '$categori_show_list', 
			`categori_language`		= '$categori_language' ,
			 `categori_show` 		= '$categori_show'
			
			
			WHERE  `categori_id` = '$id'
			
			");

			$ok = "done";
		}
	
		if(!$ok) {




	
		?>

<div class="clear"> </div>

<div class="wrapper">

<div class="menu radius flt">
<?php include("./template/menu.php") ?>
 </div>

<div class="wrapperInside radius flt"> 

<div class="wrapperInsideCapture"> Category Edit</div>

<div class="wpForm"> 

<form class="validate" name="form1" method="post" id="save" enctype="multipart/form-data"  >
	
<div class="wpFormLabelBox">
<div class="wpFormLabel"> Category Name</div>
<div class="wpFormText radius"> <input name="categori_name" type="text" value="<?=$row['categori_name'];?>"/></div>
</div>

<div class="wpFormLabelBox">
<div class="wpFormLabel"> Category (Chinese)Name</div>
<div class="wpFormText radius"> <input name="categori_namecn" type="text" value="<?=$row['categori_namecn'];?>"/></div>
</div>


<div class="wpFormLabelBox">
<div class="wpFormLabel ">Category Detail</div>
<div class="wpFormText" style="display:block; height:100%;">
<textarea name="categori_info" id="textarea" cols="45"rows="5" /  class="mceEditor"><?=$row['categori_info'];?></textarea>
</div>
</div>


<div class="wpFormLabelBox">
<div class="wpFormLabel ">Category (Chinese)Detail</div>
<div class="wpFormText" style="display:block; height:100%;">
<textarea name="categori_infocn" id="textarea" cols="45"rows="5" class="mceEditor"><?=$row['categori_infocn'];?></textarea>
</div>
</div>


<div class="wpFormLabelBox">
<div class="wpFormLabel"> Category Photo</div>

<?php if(!empty($row['categori_photo'])):?>
<img src="../upload/categori/<?=$row['categori_photo'];?>" ><?php else: ?> <img src="../upload/categori/noneimg.jpg"> <?php endif; ?><br>
<input type="file" class="nicefileinput wpFormUpload" name="dosya" id="fileField"  />

</div>





<div class="wpFormLabelBox">
<div class="wpFormLabel">Category Order List </div>


<div class="wpFormSelecet radius" >

<select name="categori_show_list" class="turnintodropdown radius"  >
<option name="categori_show_list"> <?=$row['categori_show_list'];?></option>
<?php
 for( $i=0; $i<=100; $i++ )
{
?>
<option name ="categori_show_list">
<?php 
echo $i;
echo "<br>"; ?>
</option>
<?php
}
?>

</select>
</div>
</div>

<div class="wpFormLabelBox">
<div class="wpFormLabel"> Category Language</div>
<div class="wpFormCheck"> 
<input id="radio1" type="radio" name="categori_language" value="1" <?php if($row['categori_language'] == 1 ) echo"checked";?> > <label for="radio1"> English </label>
 </div>
</div>







<div class="wpFormLabelBox">
<div class="wpFormLabel">Show Page</div>
<div class="wpFormCheck"> 
<input id="radio1" type="radio" name="categori_show" value="1" <?php if($row['categori_show'] == 1 ) echo"checked";?> >  <label> Yes </label>
<input id="radio1" type="radio" name="categori_show" value="0" style="margin-left:24px;" <?php if($row['categori_show'] == 0 ) echo"checked";?>>  <label> No</label>
 </div>
</div>


<div class="wpFormLabelBox">
<div class="wpFormButton">
<input type="submit" name="save"  id="save" value="Save" class="radius">
</div>
</div>


</form>


   
</div>

<?php }	if ($ok == "done"): ?>
<div class="welldone"><img src="images/ok.jpg" width="300" height="300"><br>
Your process well done !<br><a href="categoriList.php">:: OK :: </a> </div>
<?php endif; ?>
</div>
</div>







<?php include("template/footer.php") ?>

<?php 

function upload_pic($file)
{
	$upload = new upload($file);
	$new_name = substr(md5(time()),0,6).substr(md5(rand(0,100000)),0,6);
	#big
	$upload->file_new_name_body     = $new_name;
	$upload->process('../upload/categori/');
	if($upload->processed){
		$upload->clean();
		return $new_name.'.jpg';
	}
	return 'Hata:'.$upload->error;
}
?>
